/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * Name       : 装置详细信息查看
 */
var fieldLabel = new Array('供电局','部门分县局','监测点类型','电网类型','监测点名称','电压等级(kV)','电压上限(V)','电压下限(V)','测点地域','测点位置',
                           '供电所','所属变电站电压等级(kV)','用户名称','公变名称','安装位置','生产厂家','装置类别','装置型号','通讯方式','通信卡号',
                           'IP地址','终端地址','安装日期','校验日期','生效日期','状态','启用/停用','停用日期','停用原因');//,'有效期',
                           //'出厂日期','端口','唯一码','监测点ID','组编码','行政区域吗','通道','在线情况','管理人员','备注'
var fieldName=new Array("company","subCompany","pointTypeId","pointType2","name","voltageLevelName","upperLimit","lowerLimit","pointArea","pointPosition",
                        "shortName","stationVoltageLevel","userName","publicName","installSite","manufactoryName","deviceType","model","commTypeName","mobileNo",
                        "ip","terminalNo","installTime","checkTime","effectTime","status","status","stopTime","stopReason");//,"yxq",
                        //"ccrq","port","wym","id","zbm","xzqym","td","zxqk","glry","bz"
var _pageSize=20;


var store=new Ext.data.JsonStore({    
    url: "../../../servlet/system/PointLoad",
    root: 'data',
    idProperty: 'id',
    totalProperty: 'count',
    fields: fieldName,
    autoLoad: true,
    baseParams: {start: 0, limit: _pageSize,cmd:'general'}
});

var centercolumnModel = new Ext.grid.ColumnModel({
    columns: [
    new Ext.grid.RowNumberer({
        header : '序号',
        align: 'center', 
        width : 40/*,
        renderer: function (value, metadata, record, rowIndex) {
            return record_start + 1 + rowIndex;
        }*/        
    }),
    {header: fieldLabel[0],width: 100, dataIndex: fieldName[0], align: 'center'},
        {header: fieldLabel[1],width: 100, dataIndex: fieldName[1], align: 'center'},
        {header: fieldLabel[2],width: 100, dataIndex: fieldName[2], align: 'center'},
        {header: fieldLabel[3],width: 100, dataIndex: fieldName[3], align: 'center'},
        {header: fieldLabel[4],width: 100, dataIndex: fieldName[4], align: 'center'},
        {header: fieldLabel[5],width: 100, dataIndex: fieldName[5], align: 'center'},
        {header: fieldLabel[6],width: 100, dataIndex: fieldName[6], align: 'center'},
        {header: fieldLabel[7],width: 100, dataIndex: fieldName[7], align: 'center'},
        {header: fieldLabel[8],width: 100, dataIndex: fieldName[8], align: 'center'},
        {header: fieldLabel[9],width: 100, dataIndex: fieldName[9], align: 'center'},
        
        {header: fieldLabel[10],width: 100, dataIndex: fieldName[10], align: 'center'},
        {header: fieldLabel[11],width: 100, dataIndex: fieldName[11], align: 'center'},
        {header: fieldLabel[12],width: 100, dataIndex: fieldName[12], align: 'center'},
        {header: fieldLabel[13],width: 100, dataIndex: fieldName[13], align: 'center'},
        {header: fieldLabel[14],width: 100, dataIndex: fieldName[14], align: 'center'},
        {header: fieldLabel[15],width: 100, dataIndex: fieldName[15], align: 'center'},
        {header: fieldLabel[16],width: 100, dataIndex: fieldName[16], align: 'center'},
        {header: fieldLabel[17],width: 100, dataIndex: fieldName[17], align: 'center'},
        {header: fieldLabel[18],width: 100, dataIndex: fieldName[18], align: 'center'},
        {header: fieldLabel[19],width: 100, dataIndex: fieldName[19], align: 'center'},
        
        {header: fieldLabel[20],width: 100, dataIndex: fieldName[20], align: 'center'},
        {header: fieldLabel[21],width: 100, dataIndex: fieldName[21], align: 'center'},
        {header: fieldLabel[22],width: 100, dataIndex: fieldName[22], align: 'center'},
        {header: fieldLabel[23],width: 100, dataIndex: fieldName[23], align: 'center'},
        {header: fieldLabel[24],width: 100, dataIndex: fieldName[24], align: 'center'},
        {header: fieldLabel[25],width: 100, dataIndex: fieldName[25], align: 'center'},
        {header: fieldLabel[26],width: 100, dataIndex: fieldName[26], align: 'center'},
        {header: fieldLabel[27],width: 100, dataIndex: fieldName[27], align: 'center'},
        {header: fieldLabel[28],width: 100, dataIndex: fieldName[28], align: 'center'},
        {header: fieldLabel[29],width: 100, dataIndex: fieldName[29], align: 'center'}
        
        //{header: fieldLabel[30],width: 100, dataIndex: fieldName[30], align: 'center'},
        //{header: fieldLabel[31],width: 100, dataIndex: fieldName[31], align: 'center'},
        ///{header: fieldLabel[32],width: 100, dataIndex: fieldName[32], align: 'center'},
        //{header: fieldLabel[33],width: 100, dataIndex: fieldName[33], align: 'center'},
        //{header: fieldLabel[34],width: 100, dataIndex: fieldName[34], align: 'center'},
        //{header: fieldLabel[35],width: 100, dataIndex: fieldName[35], align: 'center'},
        //{header: fieldLabel[36],width: 100, dataIndex: fieldName[36], align: 'center'},
        //{header: fieldLabel[37],width: 100, dataIndex: fieldName[37], align: 'center'},
        //{header: fieldLabel[38],width: 100, dataIndex: fieldName[38], align: 'center'},
        //{header: fieldLabel[39],width: 100, dataIndex: fieldName[39], align: 'center'},
    ],
    defaultSortable: true
});

var pointTypeStore = new Ext.data.JsonStore({
    url: '../../../servlet/common/SimpleInfoLoad',
    baseParams: {
        id: 'id', 
        name: 'name', 
        tableName: 't_pointType'
    },
    autoLoad: true,
    root: 'data',
    fields: ['id', 'name']
});

var pointTypeCombo = {
    xtype: 'combo',
    store: pointTypeStore,
    id: 'PointTypeCombo',
    displayField: 'name',
    valueField: 'id',
    hiddenName: 'pointTypeId',    
    mode: 'remote', 
    forceSelection: true,
    allowBlank: false,
    blankText: '不允许为空',
    triggerAction: 'all',
    fieldLabel: '监测点类型',
    emptyText: '请选择监测点类型...',
    selectOnFocus: true
};

var pointTypeStore1 = new Ext.data.JsonStore({
    url: '../../../servlet/common/SimpleInfoLoad',
    baseParams: {
        id: 'id', 
        name: 'name', 
        tableName: 't_pointType2'
    },
    autoLoad: true,
    root: 'data',
    fields: ['id', 'name']
});

var pointTypeCombo2 = {
    xtype: 'combo',
    store: pointTypeStore1,
    id: 'PointTypeCombo2',
    displayField: 'name',
    valueField: 'id',
    hiddenName: 'pointType2Id',    
    mode: 'remote', 
    forceSelection: true,
    allowBlank: false,
    blankText: '不允许为空',
    triggerAction: 'all',
    fieldLabel: '城农网类别',
    emptyText: '请选择城农网类别...',
    selectOnFocus: true
};
var apertureCombo={
        xtype:'combo',
        width:120,
        fieldLabel: '全口径',
        mode: 'local',
        emptyText: '选择口径类型...',
        allowBlank: false,
        //msgTarget: 'side',
        id: 'aperture',
        triggerAction: 'all',
        forceSelection:true,
        store: new Ext.data.ArrayStore({
            fields: [
            'id',
            'apertureType'
            ],
            data: [['1', '全口径'], ['2', '母口径'],['3', '子口径']]
        }),
        valueField: 'id',
        displayField: 'apertureType',
        anchor: '50%'
    };
var statisticalTypeCombo={
        xtype:'combo',
        width:120,
        fieldLabel: '全部',
        mode: 'local',
       emptyText: '选择上报类型...',
        allowBlank: false,
        //msgTarget: 'side',
        id: 'statisticalType',
        triggerAction: 'all',
        forceSelection:true,
        store: new Ext.data.ArrayStore({
            fields: [
            'id',
            'statisticalType'
            ],
            data: [['1', '全部'], ['2', '上报'],['3', '观测']]
        }),
        valueField: 'id',
        displayField: 'statisticalType',
        anchor: '50%'
    };
var centergrid=new Ext.grid.GridPanel({
    title: '装置详细信息查看',
    store: store,
    colModel:centercolumnModel,
    enableColumnMove: false,
    viewConfig: {
        forceFit: false
    },
    
    loadMask: true,
    tbar: new Ext.Toolbar([
        pointTypeCombo,'-',
        pointTypeCombo2,'-',
        apertureCombo,'-',
        statisticalTypeCombo,'-',
        {
        xtype:'textfield',
        id:'name',
        emptyText: '- -请输入监测点名称- -' 
        },'-',
    {
        xtype: 'button',
        text: '搜索',
        iconCls: 'icon-search',
        width: 60,
        style: {
            marginLeft: '20px'
        },
        handler: function() {
            store.load({
                params: {
                    start: 0, 
                    limit: _pageSize
                }
            });
        }
    },
    '-',
    {
        xtype: 'button',
        text: '导出',
        iconCls: 'icon-excel',
        width: 60,
        style: {
            marginLeft: '20px'
        },
        handler: downloadExcel
    }
    ]),
    bbar: new Ext.PagingToolbar({
        pageSize: _pageSize,
        store: store,
        displayInfo: true,
        displayMsg: '显示记录：{0} - {1}   总记录：{2}',
        emptyMsg:  '目前没有信息'
    })
});


function downloadExcel(){
    var datefrom=DateFrom.value;
    var dateto=DateTo.value;
    var PointType = PointTypeCombo.value;
    var PointType2 = PointTypeCombo2.value;
    params={
        PointType:PointType,
        PointType2:PointType2,
        datefrom:datefrom,
        dateto:dateto
    };
    var encodeParams = Ext.urlEncode(params);
    open('../../servlet/ExcelFileCreate?'+encodeParams);
}

function buildWindow(){
    var applicationUI = new Ext.Viewport({
        layout:'fit',
        items: [
        centergrid
        ]
    });
}
Ext.onReady(buildWindow); 

